<template>
  <div id="expenditure">
    <p class="perTitle" style="border: none;"><i></i><span>U币使用记录</span></p>
        <ul class="usage">
            <li v-for="(li, index) in lists" :key="index">
                <span class="reson">{{li.type}}:</span>
                <span class="integral">
                    <span v-if="li.is_cost == 1">+</span>
                    <span v-else>-</span>
                    <span style="color: #10a57d;margin: 0 5px">{{li.amount}}</span>U币</span>
                <span class="time">{{li.pay_time}}</span>
            </li>
        </ul>
        <el-pagination
                background
                :current-page="current"
                layout="prev, pager, next"
                :page-size="pager"
                :total="total"
                 @size-change="handleSizeChange"
                 @current-change="handleCurrentChange">
        </el-pagination>
  </div>
</template>

<script>
export default {
  name: 'expenditure',
  data () {
    return {
      lists: [],
      info: [],
      reason: [],
      // page:'1',
      current: '1',
      pager: '',
      total: ''
    };
  },
  mounted () {
    this.pageI();
  },
  methods: {
    pageI () {
      this.axios.get('user/wallet-logs', {
        params: {
          page: this.current
        }
      })
        .then(({data}) => {
          if (data.code === 200) {
            console.log(data);
            this.lists = data.data.data;
            this.current = data.data.current;
            this.pager = data.data.per_page;
            this.total = data.data.total;
          } else {
            this.$message({
              message: data.msg,
              type: 'warning'
            });
          }
        })
        .catch(function (error) {
          console.log(error);
        });
    },
    handleSizeChange: function (val) {
      console.log(val);
    },
    handleCurrentChange: function (val) {
      console.log(val);
      this.current = val;
      this.pageI();
    }
  }
};
</script>

<style lang="scss">
#expenditure {
  .el-pagination {
    text-align: center;
    margin-top: 20px;
  }
  .el-pagination.is-background .el-pager li:not(.disabled).active {
    background-color: #10a57d;
    color: #fff;
  }
  .perTitle {
    /*padding: 10px 0;*/
    height: 40px;
    border-bottom: 1px solid #dfdfdf;
    font-size: 16px;
  }
  .perTitle i {
    width: 5px;
    display: inline-block;
    height: 16px;
    vertical-align: middle;
    background-color: #10a57d;
    line-height: 40px;
    margin: 0 10px;
  }
  .usage {
    border: 1px solid #dfdfdf;
  }
  .usage li {
    border-bottom: 1px solid #dfdfdf;
    padding: 17px 0;
  }
  .usage li span {
    display: inline-block;
    color: #151515;
  }
  .usage li .reson {
    width: 40%;
    text-align: center;
  }
  .usage li .integral {
    width: 25%;
  }
  .usage li .time {
    width: 33%;
    text-align: center;
    color: #999999;
  }
}
</style>
